<%--
    Document   : index
    Created on : 30 avr. 2012, 19:06:33
    Author     : aurelie
--%>

<%@page contentType="text/html" pageEncoding="UTF-8"%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
    "http://www.w3.org/TR/html4/loose.dtd">

<!-- Ne pas oublier cette ligne sinon tous les tags de la JSTL seront ignorés ! -->
<%@taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>

<!DOCTYPE html>
<html>
    <head>
        <title>Buy Movies</title>
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
        <meta http-equiv="imagetoolbar" content="no" />
        <link rel="stylesheet" href="styles/menu.css" type="text/css" />
        <script type="text/javascript" src="scripts/menu.js"></script>
        <link rel="stylesheet" href="styles/layout.css" type="text/css" />
        <!-- script qui calcule le montant -->
        <SCRIPT TYPE="text/javascript">
            <!-- 
            function orderTotal(oform, prefix)
            {
                // set references to fields
                var qty = oform[prefix + "_qty"];
                var stHold = oform[prefix + "_stHold"];
                var price = oform[prefix + "_price"];
                var stVis = oform[prefix + "_stVis"];

                // only bother if the field has contents
                if (qty == "")return;

                // if the with is not a number (NaN)
                // or is zero or less
                // everything goes blank
                if(isNaN(qty.value) || (qty.value <= 0))
                {
                    qty.value = "";
                    stHold.value = "";
                }
   
                // else the field is a valid number, so calculate the 
                // total order cost and put that value in the 
                // hidden subtotal field
                else
                    stHold.value = (Math.round(qty.value * price.value * 100))/100;

                // call the routine which checks if the 
                // visible subtotal is correct
                visTotal(oform, prefix);
            }

            // checks if the visible subtotal is correct
            // ie, if it equals the hidden subtotal field
            function visTotal(oform, prefix)
            {
                var stHold = oform[prefix + "_stHold"];
                var stVis = oform[prefix + "_stVis"];

                if (stVis.value != stHold.value)
                    stVis.value = stHold.value;
            }
            // -->
        </SCRIPT>

    </head>
    <body id="top">
        <div class="wrapper col0">
            <div id="topbar">
                <ul id="menu"><c:if test="${connecte}">
                        <li><a href="ServletAuthentification?action=deconnection">Déconnection</a></li>

                    </c:if>
                    <c:if test="${!connecte}">
                        <li><a href="ServletAuthentification?action=authentifier">Se connecter</a></li>
                    </c:if>

                    <li class="last"><a href="ServletPanier?action=panier">Mon Panier</a></li>
                    


                    <c:if test="${connecte}">
                        <p> ${message}</p>
                    </c:if>

                </ul>
                <br class="clear" />
            </div>
        </div>
        <!-- ####################################################################################################### -->
        <div class="wrapper col1">
            <div id="header">
                <div id="topnav">
                    <ul>
                        <li><a href="ServletFilm?action=listerFilms&categorie=all">Tous les films</a><span></span></li>
                        <li><a href="ServletFilm?action=listerFilms&categorie=null">Films par catégorie</a><span></span></li>
                        <li class="active"><a href="ServletFilm">Accueil</a><span>Nouveautés</span></li>
                    </ul>
                </div>
                <div id="logo">
                    <h1><a href="ServletAuthentification?action=index">Buy Movies</a></h1>
                    <p>Ne restez plus simple spectateur</p>
                </div>
                <br class="clear" />
            </div>
        </div>
        <!-- ####################################################################################################### -->
        <div class="wrapper col2">
            <div id="breadcrumb">
                <ul>
                    <li class="first">You Are Here</li>
                    <li>&#187;</li>
                    <li><a href="ServletAuthentification?action=index">Accueil</a></li>
                    <li>&#187;</li>       

                    <li class="current">Votre panier</li>
                </ul>
            </div>
        </div>
        <!-- ####################################################################################################### -->
        <div class="wrapper col3">
            <div id="container">
                <div id="content">

                    <c:if test="${param['action'] == 'panier'}">
                        <c:set var="total" value="0"/>

                        <c:forEach var="f" items="${ajoutPanier}">
                            <FORM ACTION="">
                            <TABLE BORDER CELLPADDING=3>
                                <!-- table titles -->
                                <TR >
                                    <TD>Film</TD>                                   
                                    <TD>Prix</TD>                                    
                                </TR>

                                <TR >
                                    <TD>${f.titre} <img class="imgr" src="${f.affiche}" alt="" width="50" height="70" /></TD>                                    
                                    <TD><INPUT TYPE=HIDDEN NAME="vn_price" VALUE="${f.prixDVD}">${f.prixDVD} €</TD>                                    
                                </TR>

                            </TABLE>
                            </form>
                           

                            <!-- On compte le nombre de users -->
                            <c:set var="total" value="${total+1}"/>
                            <!-- On calcule le montant du panier -->
                            <c:set var="montant" value="${montant}"/>
                            </script>
                        </c:forEach>



                        Montant Total : <script type="text/javascript">getQuantiteDVD()</script>
                        ${montant} €
                        <!-- Affichage du solde total dans la dernière ligne du tableau -->
                        <p>Vous avez <b>${total}</b> films dans votre panier <br/></p>

                        <a href="ServletPanier?action=panierValide&connecte=${connecte}" class="myButton">Valider mon panier </a>
                        <a href="ServletPanier?action=continuerAchat" class="myButton">Continuer mes achats </a>  
                        <a href="ServletPanier?action=supprimerPanier" class="myButton">Supprimer mon panier </a>  

                    </c:if>



                </div>

                <br class="clear" />
            </div>
        </div>
        <div class="wrapper col4">
            <div id="footer">
                <div class="footbox">
                    <h2>Contact</h2>
                    <ul>
                        <li><a href="mailto:sophie.tournes@gmail.com">Sophie Tournès</a></li>
                        <li class="last"><a href="mailto:aureliefolacci@gmail.com">Aurélie Folacci</a></li>

                    </ul>
                </div>
                <div class="footbox">
                    <h2>Liens</h2>
                    <ul>
                        <li><a href="http://www.allocine.fr">Allocine</a></li>
                        <li class="last"><a href="http://www.pathe.fr">Pathe Gaumont</a></li>
                    </ul>
                </div>

                <br class="clear" />
            </div>
        </div>
        <div class="wrapper col5">
            <div id="copyright">
                <p class="fl_left">Copyright &copy; 2012 - All Rights Reserved - <a href="#">Aurélie Folacci et Sophie Tournès</a></p>
                <br class="clear" />
            </div>
        </div>
    </body>
</html>
